import * as Utils from './util.js';
import * as Ajax from './ajax.js';
import * as Inface from './interface.js';

var codeUrl = Inface.interFace.url5,
    codeAc = Utils.getLocationStorage("accessToken"),
    codeId = Utils.getLocationStorage("showID"),
    // codeDt = localStorage.getItem("day_time").replace(/\"/g, ""),
    codeName = Utils.getLocationStorage("uname"),
    input = document.querySelector('input'),
    img = document.querySelector('img'),
    btn = document.querySelector('button'),
    codeData = {
        token : codeAc,
        id : codeId,
        // day_time : codeDt,
        // uname : codeName
    };

    // console.log(codeId);
// console.log(codeAc,codeId);

// console.log("data",codeData);


input.value = codeName;

Ajax.getData(codeUrl,codeData,"get")
    .then((res) => {
        // console.log(res);
        img.src = res.data.data
    })
    


//点击下载图片
btn.addEventListener('click',() => {
    let a = document.querySelector('a');
    a.download = "下载";
    a.href = img.src;
    a.dispatchEvent(new MouseEvent('click', {}))

})


